package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.bifang.engine.protect.core.annotation.NoSignCrypto;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduSendContent.EduSendContentKeyVO;
import com.jwsoft.manager.common.vo.eduSendContent.EduSendContentQueryVO;
import com.jwsoft.manager.common.vo.eduSendContent.EduSendContentVO;
import com.jwsoft.manager.common.vo.eduSendMessageModel.EduSendMessageModelVO;
import com.jwsoft.manager.core.integration.EduSendContentIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 短信内容结果表网关
 *
 * @author zjl
 * @since 2024-06-28
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "短信内容结果表", description = "短信内容结果表")
public class EduSendContentController {

    @Autowired
    public EduSendContentIntegration eduSendContentIntegration;

    @Operation(summary = "短信内容结果表分页查询",description = "短信内容结果表分页查询")
    @PostMapping(value = "/eduSendContent0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSendContentVO>> getList(@RequestBody @Validated EduSendContentQueryVO vo) {
        return AppResponse.successData(eduSendContentIntegration.getList(vo));
    }

    @Operation(summary = "短信内容结果表根据主键查询详情",description = "短信内容结果表根据主键查询详情")
    @PostMapping(value = "/eduSendContent0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSendContentVO> getById(@RequestBody @Validated EduSendContentKeyVO vo) {
        return AppResponse.successData(eduSendContentIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "短信内容结果表新增",description = "短信内容结果表新增")
    @PostMapping(value = "/eduSendContent0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSendContentVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSendContentVO vo) {
        return AppResponse.successData(eduSendContentIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "短信内容结果表修改",description = "短信内容结果表修改")
    @PostMapping(value = "/eduSendContent0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSendContentVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSendContentVO vo) {
        return AppResponse.successData(eduSendContentIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "短信内容结果表删除",description = "短信内容结果表删除")
    @PostMapping(value = "/eduSendContent0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSendContentKeyVO vo) {
        eduSendContentIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "发送单条短信",description = "发送单条短信")
    @PostMapping(value = "/eduSendContent0007", produces = "application/json;charset=UTF-8")
    public AppResponse<Boolean> sendSingleMessage (@RequestBody @Validated EduSendContentQueryVO vo) {
        return AppResponse.successData(eduSendContentIntegration.sendSingleMessage(vo));
    }
    @Operation(summary = "查询短信编号",description = "查询短信编号")
    @PostMapping(value = "/eduSendContent0008", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduSendMessageModelVO>> queryMessageNumber (@RequestBody @Validated EduSendContentQueryVO vo) {
        return AppResponse.successData(eduSendContentIntegration.queryMessageNumber(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "批量修改短信状态",description = "批量修改短信状态")
    @PostMapping(value = "/eduSendContent0009", produces = "application/json;charset=UTF-8")
    public AppResponse updateMessageStatus (@RequestBody @Validated EduSendContentQueryVO vo) {
        eduSendContentIntegration.batchUpdateMessageStatus(vo);
        return AppResponse.success();
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "批量修改短信状态",description = "批量修改短信状态")
    @PostMapping(value = "/eduSendContent0010", produces = "application/json;charset=UTF-8")
    public AppResponse batchSendMessage (@RequestBody @Validated EduSendContentQueryVO vo) {
        eduSendContentIntegration.batchSendMessage(vo);
        return AppResponse.success();
    }
    @NoSignCrypto
    @Operation(summary = "发送短信测试接口",description = "发送短信测试接口")
    @PostMapping(value = "/eduSendContent0011", produces = "application/json;charset=UTF-8")
    public AppResponse sendMessageTest (@RequestBody @Validated EduSendContentQueryVO vo) {
        eduSendContentIntegration.sendMessageTest(vo);
        return AppResponse.success();
    }
}
